﻿<UserControl x:Class="Mengsk.ProxyDelivery.App.UI.Delivery.DeliveryOutQueryUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
              xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             d:DesignHeight="300" d:DesignWidth="1400" Loaded="UserControl_Loaded">
    <Grid Grid.Column="1">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0" Orientation="Horizontal" >
            <TextBlock Text="订单编号:" Margin="3" VerticalAlignment="Center"/>
            <TextBox Name="tbOrderId" Margin="3" VerticalAlignment="Center" Width="80"/>
            <TextBlock Text="卖家编号:" Margin="3" VerticalAlignment="Center"/>
            <TextBox Name="tbSellerId" Margin="3" VerticalAlignment="Center" Width="80"/>
            <TextBlock Text="快递公司:" Margin="3" VerticalAlignment="Center"/>
            <ComboBox Name="cbbDeliveryCompany" Margin="3" VerticalAlignment="Center" Width="100"/>
            <TextBlock Text="运单编号:" Margin="3" VerticalAlignment="Center"/>
            <TextBox Name="tbDeliveryNumber" Margin="3" VerticalAlignment="Center" Width="100" />
            <TextBlock Text="发货人员:" Margin="3" VerticalAlignment="Center"/>
            <TextBox Name="tbOpeator" Margin="3" VerticalAlignment="Center" Width="80" />
            <TextBlock Text="开始时间:" Margin="3" VerticalAlignment="Center"/>
            <xctk:DateTimePicker Name="dpStart" Margin="3" VerticalAlignment="Center" Width="140" Format="Custom" FormatString="yyyy-MM-dd HH:mm:ss"/>
            <TextBlock Text="结束时间:" Margin="3" VerticalAlignment="Center"/>
            <xctk:DateTimePicker Name="dpEnd" Margin="3" VerticalAlignment="Center" Width="140"  Format="Custom" FormatString="yyyy-MM-dd HH:mm:ss"/>
            <Button Name="btnSearch" Content="查询" Margin="3" VerticalAlignment="Center" Width="60" Click="btnSearch_Click"/>

        </StackPanel>


        <TabControl Grid.Row="1" x:Name="tcOrderPages">
            <TabControl.ItemContainerStyle>
                <Style TargetType="{x:Type TabItem}">
                    <Setter Property="HeaderTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <TextBlock Text="{Binding DeliveryCompany}"/>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>

                    <Setter Property="ContentTemplate">
                        <Setter.Value>
                            <DataTemplate>
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <StackPanel Grid.Row="0" Orientation="Horizontal">
                                        <CheckBox Content="全选" Margin="3" VerticalAlignment="Center" Checked="CheckBox_CheckedChanged" Unchecked="CheckBox_CheckedChanged" Tag="{Binding}"/>
                                        <TextBlock Text="{Binding CountInfo}" Margin="3" VerticalAlignment="Center"/>
                                        <Button Name="btnExport" Margin="3" VerticalAlignment="Center" Content="导出" Width="80" DataContext="{Binding}" Click="btnExport_Click"/>
                                        <Button Name="btnExportMoney" Content="导出金额" Margin="3" Width="80" DataContext="{Binding}"  VerticalAlignment="Center" Click="btnExportMoney_Click"/>
                                    </StackPanel>
                                    <DataGrid ItemsSource="{Binding Sources}" Grid.Row="1" IsReadOnly="True" Margin="3" HorizontalScrollBarVisibility="Auto" GridLinesVisibility="All"
											AutoGenerateColumns="False" 
											CanUserAddRows="False"
											CanUserDeleteRows="False"
											CanUserResizeRows="False"
											RowHeaderWidth="25"
											SelectionMode="Extended"
											SelectionUnit="FullRow">
                                        <DataGrid.RowHeaderStyle>
                                            <Style TargetType="{x:Type DataGridRowHeader}">
                                                <Setter Property="ContentTemplate">
                                                    <Setter.Value>
                                                        <DataTemplate>
                                                            <CheckBox IsChecked="{Binding DataContext.IsChecked, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridRow}}, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                                        </DataTemplate>
                                                    </Setter.Value>
                                                </Setter>
                                            </Style>
                                        </DataGrid.RowHeaderStyle>
                                        <DataGrid.Columns>
                                            <DataGridTextColumn Header="发货编号" Binding="{Binding Source.Id}" Width="Auto"/>
                                            <DataGridTextColumn Header="订单编号" Binding="{Binding Source.OrderId}" Width="Auto"/>
                                            <DataGridTextColumn Header="卖家编号" Binding="{Binding Source.SellerId}" Width="Auto"/>
                                            <DataGridTextColumn Header="物流单号" Binding="{Binding Source.DeliveryNumber}" Width="Auto"/>
                                            <DataGridTextColumn Header="重量" Binding="{Binding Source.Weight,StringFormat=F2}" Width="Auto"/>
                                            <DataGridTextColumn Header="发货时间" Binding="{Binding Source.CreateTime,Converter={StaticResource datetimeConverter}}" Width="Auto"/>
                                            <DataGridTextColumn Header="收货地址" Binding="{Binding Source.ReceiverAddress}" Width="Auto"/>
                                        </DataGrid.Columns>
                                    </DataGrid>
                                </Grid>
                            </DataTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </TabControl.ItemContainerStyle>
        </TabControl>
    </Grid>
</UserControl>
